﻿@model AccountDropdownModel

@using SmartStore.Web.Models.Common;
@using SmartStore.Web.Models.Customer;
@using SmartStore.Core;
@using SmartStore.Core.Infrastructure;
@using SmartStore.Core.Infrastructure.DependencyManagement;
@{
	//register URL with return URL (if specified)
	var registerUrl = Url.RouteUrl("Register");
	if (!String.IsNullOrEmpty(this.Context.Request.QueryString["returnUrl"]))
	{
		var webHelper = EngineContext.Current.Resolve<IWebHelper>();
		registerUrl = webHelper.ModifyQueryString(registerUrl, "returnUrl=" + HttpUtility.UrlEncode(this.Context.Request.QueryString["returnUrl"]), null);
	}

	var isRtl = this.WorkContext.WorkingLanguage.Rtl;
}

@if (Model.IsAuthenticated)
{
    <div class="dropdown-menu @(isRtl ? "dropdown-menu-left" : "dropdown-menu-right")">
        
        @{ Html.RenderWidget("account_dropdown_before"); }

		<a class="dropdown-item" href="@Url.Action("Info", "Customer")" rel="nofollow">
			<i class="fal fa-user fa-fw"></i>
			<span>@T("Account.MyAccount")</span>
		</a>

        @if (Model.DisplayAdminLink)
        {
            <a class="dropdown-item" href="@Url.Content("~/admin")" target="_admin" rel="nofollow">
                <i class="fal fa-cog fa-fw"></i> 
				<span>@T("Account.Administration")</span>
            </a>
        }
        
        @if (Model.AllowPrivateMessages)
        {
			<a class="dropdown-item" href="@Url.RouteUrl("PrivateMessages", new { tab = "inbox" })" rel="nofollow">
				<i class="fal fa-envelope fa-fw"></i>
				<span>@T("PrivateMessages.Inbox")</span>
				@if (Model.UnreadPrivateMessages != "")
				{
					<span class="badge badge-success">@Model.UnreadPrivateMessages</span>
				}
			</a>
			if (!string.IsNullOrEmpty(Model.AlertMessage))
            {
                <script type="text/javascript">
                    $(document).ready(function () {
                        displayNotification('@(Model.AlertMessage)', 'info');
                    });
                </script>
            }
        }
        
        @*<li class="divider"></li>*@

        @if (Model.WishlistEnabled)
        {
            <a class="dropdown-item" href="@Url.RouteUrl("Wishlist")">
                <i class="fal fa-heart fa-fw"></i>
				<span>@T("Wishlist")</span> 
				<span class="wishlist-qty badge badge-success @(Model.WishlistItems > 0 ? "label-success" : "d-none")">@Model.WishlistItems</span>
			</a> 
        }
        @if (Model.ShoppingCartEnabled)
        {
            <a id="topcartlink" class="dropdown-item" href="@Url.RouteUrl("ShoppingCart")">
                <i class="fal fa-shopping-bag fa-fw"></i>
				<span>@T("ShoppingCart")</span> 
				<span class="cart-qty badge badge-success @(Model.ShoppingCartItems > 0 ? "label-success" : "d-none")">@Model.ShoppingCartItems</span>
			</a>
        }
        <div class="dropdown-divider"></div>
        <a class="dropdown-item" href="@Url.RouteUrl("Logout")" rel="nofollow">
            <i class="fal fa-sign-out-alt fa-fw"></i>
			<span>@T("Account.Logout")</span>
		</a>

        @{ Html.RenderWidget("account_dropdown_after"); }

    </div>
}